package com.kedll.library.location.entity;

import android.os.Parcel;
import android.os.Parcelable;

import com.alibaba.fastjson.JSON;

/**
 * @author 华哥
 * @date 2016/9/22
 * 位置信息实体类
 */
public class LocationEntity implements Parcelable {
    //位置描述
    private String locationDescribe;
    // 城市信息
    private String city;
    private double lan;
    private double lng;
    //省份
    private String province;
    //地区
    private String district;
    //街道
    private String street;
    //门牌号
    private String streetNum = "";
    private float radius;

    public double getLan() {
        return lan;
    }

    public void setLan(double lan) {
        this.lan = lan;
    }

    public double getLng() {
        return lng;
    }

    public void setLng(double lng) {
        this.lng = lng;
    }

    public String getLngLat() {
        return String.format("%s,%s", lng, lan);
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getAddress() {
        return String.format("%s%s%s%s%s",
                getProvince(), getCity(), getDistrict(), getStreet(), getStreetNum());
    }


    public String getLocationDescribe() {
        return locationDescribe;
    }

    public void setLocationDescribe(String locationDescribe) {
        this.locationDescribe = locationDescribe;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getProvince() {
        return province;
    }

    public void setDistrict(String district) {
        this.district = district;
    }

    public String getDistrict() {
        return district;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getStreet() {
        return street;
    }

    public void setStreetNum(String streetNum) {
        this.streetNum = streetNum;
    }

    public String getStreetNum() {
        return streetNum;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    public LocationEntity() {
    }

    public void setRadius(float radius) {
        this.radius = radius;
    }

    public float getRadius() {
        return radius;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.locationDescribe);
        dest.writeString(this.city);
        dest.writeDouble(this.lan);
        dest.writeDouble(this.lng);
        dest.writeString(this.province);
        dest.writeString(this.district);
        dest.writeString(this.street);
        dest.writeString(this.streetNum);
        dest.writeFloat(this.radius);
    }

    protected LocationEntity(Parcel in) {
        this.locationDescribe = in.readString();
        this.city = in.readString();
        this.lan = in.readDouble();
        this.lng = in.readDouble();
        this.province = in.readString();
        this.district = in.readString();
        this.street = in.readString();
        this.streetNum = in.readString();
        this.radius = in.readFloat();
    }

    public static final Creator<LocationEntity> CREATOR = new Creator<LocationEntity>() {
        @Override
        public LocationEntity createFromParcel(Parcel source) {
            return new LocationEntity(source);
        }

        @Override
        public LocationEntity[] newArray(int size) {
            return new LocationEntity[size];
        }
    };
}
